<template>

	<view>

		<cu-custom isBack="true" :bgColor="'bg-'+$themeColor()">
			<block slot="backText">返回</block>
			<block slot="content">专家评分</block>
		</cu-custom>
		
		<view :class="'bg-'+$bgColor()">
			<form @submit="formSubmit">
				<!-- <input name="id" :value="data.id" style="display: none;"/> -->
				<input name="scoreId" :value="data.scoreId" style="display: none;"/>
					<view class="cu-form-group ">
						<view class="title" >区域:</view>
						<input  name="region" :value="data.region" style="display: none;"></input>
						<picker @change="regionPickerChange" :value="regionPickerIndex" :range="regionPicker">
							<view class="picker">
								{{regionPickerIndex>-1?regionPicker[regionPickerIndex]:data.region}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group ">
						<view class="title" >第几次:</view>
						<input  name="timeName" :value="data.timeName" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >查看时间:</view>
						<input  name="viewTime" :value="data.viewTime" style="display: none;"></input>
						
						<picker mode="date" :value="data.viewTime" start="2015-09-01" end="2120-01-01" @change="DateChange">
							<view class="picker">
								{{$formatDate(data.viewTime) != ''  ? $formatDate(data.viewTime):'请选择'}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group ">
						<view class="title" >小区名称:</view>
						<input  name="areaName" :value="data.areaName" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >所属工程:</view>
						<input  name="belongProject" :value="data.belongProject" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >所属街道:</view>
						<input  name="belongStreet" :value="data.belongStreet" ></input>
					</view>
				
					<view class="cu-form-group ">
						<view class="title" >工程建设平均分1:</view>
						<input  name="engineeringConstructionAverage1" :value="data.engineeringConstructionAverage1" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >运营维护平均分1:</view>
						<input  name="operationMaintenanceAverage1" :value="data.operationMaintenanceAverage1" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >监督管理平均分1:</view>
						<input  name="supervisionAverage1" :value="data.supervisionAverage1" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >得分合计1:</view>
						<input  name="totalScore1" :value="data.totalScore1" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >工程建设评分2:</view>
						<input  name="engineeringConstructionScore2" :value="data.engineeringConstructionScore2" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >运营维护评分2:</view>
						<input  name="operationMaintenanceScore2" :value="data.operationMaintenanceScore2" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >监督管理评分2:</view>
						<input  name="supervisionScore2" :value="data.supervisionScore2" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >得分合计2:</view>
						<input  name="totalScore2" :value="data.totalScore2" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >工程建设评分3:</view>
						<input  name="engineeringConstructionScore3" :value="data.engineeringConstructionScore3" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >运营维护评分3:</view>
						<input  name="operationMaintenanceScore3" :value="data.operationMaintenanceScore3" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >监督管理评分3:</view>
						<input  name="supervisionScore3" :value="data.supervisionScore3" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >得分合计3:</view>
						<input  name="totalScore3" :value="data.totalScore3" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >平均分:</view>
						<input  name="average" :value="data.average" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >工程建设平均分:</view>
						<input  name="engineeringConstructionAverage" :value="data.engineeringConstructionAverage" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >运营维护平均分:</view>
						<input  name="operationMaintenanceAverage" :value="data.operationMaintenanceAverage" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >监督管理平均分:</view>
						<input  name="supervisionAverage" :value="data.supervisionAverage1" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >结论:</view>
						<input  name="conclusion" :value="data.conclusion" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >负责人:</view>
						<input  name="chargePerson" :value="data.chargePerson" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >备注:</view>
						<input  name="remark" :value="data.remark" ></input>
					</view>
					<view class="cu-form-group ">
						<view class="title" >是否授牌:</view>
						<input  name="awardState" :value="data.awardState" style="display: none;"></input>
						<switch @change="SwitchAwardState" :class="data.awardState=='是'?'checked':''" :checked="data.awardState=='是'?true:false"></switch>
						
						
						<view class="title" >是否移交:</view>
						<input  name="transferState" :value="data.transferState" style="display: none;"></input>
						<switch @change="SwitchTransferState" :class="data.transferState=='是'?'checked':''" :checked="data.transferState=='是'?true:false"></switch>
					
					</view>
					<view class="cu-form-group ">
						<view class="title" >运营单位:</view>
						<input  name="operationUnit" :value="data.operationUnit" ></input>
					</view>
					
					<view class="padding flex flex-direction">
						<button form-type="submit" class="cu-btn bg-blue margin-tb-sm lg" :disabled="submiting">提交</button>
					</view>
									
			</form>
		</view>

	</view>
</template>

<script>
	
	var content = null;
	var touchs = [];
	var canvasw = 0;
	var canvash = 0;
	var _that;
	//获取系统信息
	uni.getSystemInfo({
		success: function(res) {
			canvasw = res.windowWidth;
			canvash = res.windowHeight;
		},
	})
	export default {
		data() {
			return {
				id: '',
				scoreId:'',
				data: '',
				submiting:false,
				regionPicker:[],
				regionPickerIndex:-1,
			}
		},
		onLoad: function(opt) {
			this.scoreId = opt.scoreId;
			// 获取项目数据
			this.getProjectInfo(this.scoreId);
			
			// 获取区域信息
			this.getRegion();
		},
		mounted() {
			// 初始化加载
			
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
				this.req();
			},
			req(){
				var param = {
					"projectName":this.searchVal,
					"district":this.district,
					"pageSize":this.pageSize,
					"pageNum":this.pageNum
				}			
			},
			getProjectInfo(scoreId) {
				this.$httpGet('/system/score/getScoreById/'+scoreId , null).then(res => {
					this.data = res.data.data;
				})
			},
			regionPickerChange(e){
				this.regionPickerIndex = e.detail.value
				this.data.region = this.regionPicker[this.regionPickerIndex]
			},
			getRegion(){
				var dictData = {dictType:'zbqy_region'}
				this.$httpPost('/system/dict/data/list' , dictData).then(res => {
					// this.data = res.data.data
					var array = res.data.rows;
					var regionPicker = [];
					for (var i = 0; i < array.length; i++) {  
						// console.log(array[i].dictValue);  
						regionPicker.push(array[i].dictValue)
					}
					this.regionPicker = regionPicker;
				})
			},
			DateChange(e) {
				this.data.checkDate = e.detail.value
			},
			SwitchAwardState(e) {
				this.data.awardState = e.detail.value?'是':'否';
			},
			SwitchTransferState(e) {
				this.data.transferState = e.detail.value?'是':'否';
			},
			formSubmit(e){
				this.submiting = true;
				
				var formData = e.detail.value;
				
				this.$httpPost('/system/score/edit' , formData).then(res => {
					this.$msg(res.data.msg);
					setTimeout(() => {
						uni.navigateBack();
						this.submiting = false;
					}, 1000);
					
				})
			},
			isNull(e) {
				if (e != null) {
					return e;
				}
				return "";
			}
		
		}
	}
</script>

<style>
   .cu-form-group .title {
		min-width: calc(4em + 10px);
		text-align: right;
	}
	canvas {
		background-color: #DDDDDD;
		width: 700upx;
		margin: 0 25upx;
		height: calc(30vh - 10upx);
	}
</style>
